'use strict';
const uniPush = uniCloud.getPushManager({
	appId: "__UNI__EEBEF10"
}) //注意这里需要传入你的应用appId 


exports.main = async (event) => {

	let obj = JSON.parse(event.body);
	
	// 设置ttl
	var ttl = obj.ttl;
	if(ttl==null){
		ttl = 3 * 24 * 3600 * 1000;
	}	

	return await uniPush.sendMessage({
		"push_clientid": obj.cid, //填写上一步在uni-app客户端获取到的客户端推送标识push_clientid  
		"force_notification": obj.forceNotification, //填写true，客户端就会对在线消息自动创建“通知栏消息”。  
		"title": obj.title,
		"content": obj.content,
		"payload": obj.payload,
		"settings":{
			"ttl":ttl
		}
	})
};
